package com.wu.advapplication;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.Gravity;
import android.view.Window;
import android.view.WindowManager;
import com.wu.advapplication.utils.KeepManager;
import androidx.annotation.Nullable;

/**
 * 1像素act保活
 */
public class SinglePixelActivity extends Activity {
    private static final String TAG = "SinglePixelActivity";

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Log.e(TAG, "启动1像素Activity");
        Window window = getWindow();
        window.setGravity(Gravity.START | Gravity.TOP);
        WindowManager.LayoutParams params = window.getAttributes();
        params.width = 1;
        params.height = 1;
        params.x = 0;
        params.y = 0;
        window.setAttributes(params);
        KeepManager.getInstance().setKeepActivity(this);
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        //FixMemLeak.fixLeak(this);
        KeepManager.getInstance().finishKeep();
        Log.e(TAG, "关闭1像素Activity");
    }
}
